package com.yanqu.road.server.manger.system;

import com.yanqu.road.logic.bussiness.config.WhiteWordBussiness;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.manger.ServerListMgr;

import java.util.List;
import java.util.Objects;

public class WhiteWordMgr extends TempMgr {

	private static List<String> whiteWordList;

	@Override
	public boolean init() throws Exception {
		return reload();
	}

	@Override
	public boolean stop() {
		return false;
	}

	@Override
	public boolean save() {
		return false;
	}

	@Override
	public boolean reloadData() {
		return true;
	}

	@Override
	public boolean reloadConfig() throws Exception {
		int channelId = ServerListMgr.getChannelId(GameServer.getInstance().getServerId());
		whiteWordList = WhiteWordBussiness.getWhiteWordList(channelId);
		return true;
	}

	/**
	* 描述：是否白名单的词汇
	* 作者：zrq
	* 时间：2022/2/28
	* 参数：

	* 返回值：
	**/
	public static boolean isWhiteWord(String content) {
		for (String str : whiteWordList) {
			if (Objects.equals(str, content)) {
				return true;
			}
		}
		return false;
	}
}
